package com.lxf.clouduser.controller;

import com.alibaba.fastjson.JSONObject;
import com.lxf.clouduser.service.UserFlowAbleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 罗兴发
 * @data 2025/7/25 10:42
 * @description：工作流引擎-控制层
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
@Slf4j
public class UserFlowAbleController {
    @Resource
    UserFlowAbleService userFlowAbleService;

    /**
     * 卖家申请入驻
     * @param json
     * @param request
     * @return
     */
    @PostMapping("/appSettled")
    public String appSettled(@RequestBody JSONObject json, HttpServletRequest request){
        return userFlowAbleService.appSettled(json,request);
    }

    /**
     * 查询请假流程
     *
     * @param json
     * @param request
     *
     * */
    @PostMapping("/findTask")
    public String findTask(@RequestBody JSONObject json, HttpServletRequest request) {
        return userFlowAbleService.findTask(json,request);
    }

    /**
     * 获取审批管理列表
     *
     * @param json
     * @param request
     *
     */
    @PostMapping("/getList")
    public String getList(@RequestBody JSONObject json,HttpServletRequest request) {
        return userFlowAbleService.getList(json,request);
    }

    /**
     * 批准
     *
     * @param json
     * @param request
     */
    @PostMapping( "/apply")
    public String apply(@RequestBody JSONObject json,HttpServletRequest request) {
        return userFlowAbleService.apply(json,request);
    }

    /**
     * 驳回
     * @param json
     * @param request
     */
    @GetMapping("/reject")
    public String reject(@RequestBody JSONObject json,HttpServletRequest request) {
        return userFlowAbleService.reject(json,request);
    }

    /**
     * 生成流程图
     * @param json
     * @param request
     */
    @PostMapping("/processDiagram")
    public String genProcessDiagram(@RequestBody JSONObject json, HttpServletRequest request, HttpServletResponse response) {
        return userFlowAbleService.getProcessDiagram(json,request,response);
    }

}
